import request from '@/config/axios'

export interface AssetVO {
  id: number
  assetName: string
  department: string
  assetBrand: string
  assetModel: string
  price: number
  purchaseTime: Date
  isImport: number
  supporter: string
  contact: string
  tel: string
  location: string
  purchaser: number
  categoryId: number
  type: number
  status: number
  assetSn: string
}

export interface SimpleAssetVO {
  id: number
  assetName: string
  assetBrand: string
  assetModel: string
  location: string
}

// 查询资产管理列表
export const getAssetPage = (params: PageParam) => {
  return request.get({ url: '/bms/asset/page', params })
}

// 查询所有资产列表
export const getAllAsset = () => {
  return request.get({ url: '/bms/asset/all' })
}

// 查询资产详情
export const getAsset = (id: number) => {
  return request.get({ url: '/bms/asset/get?id=' + id })
}

// 新增资产
export const createAsset = (data: AssetVO) => {
  return request.post({ url: '/bms/asset/create', data })
}

// 修改资产
export const updateAsset = (data: AssetVO) => {
  return request.put({ url: '/bms/asset/update', data })
}

// 删除资产
export const deleteAsset = (id: number) => {
  return request.delete({ url: '/bms/asset/delete?id=' + id })
}

// 导出资产
export const exportAsset = (params) => {
  return request.download({ url: '/bms/asset/export', params })
}

// 下载资产导入模板
export const importAssetTemplate = () => {
  return request.download({ url: '/bms/asset/get-import-template' })
}

// 资产状态修改
export const updateAssetStatus = (id: number, status: number) => {
  const data = {
    id,
    status
  }
  return request.put({ url: '/bms/asset/update-status', data: data })
}

// 获取资产精简信息列表
export const getSimpleAssetList = (assetName: string) => {
  return request.get({ url: '/bms/asset/simple-list?assetName=' + assetName })
}
